package com.zhao.Util;

import com.zhao.pojo.Menu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MenuTree {
    public Object addfun(List<Menu> menus, List<HashMap<String, Object>> result) {
        for(Menu m : menus){
            HashMap<String, Object> map = new HashMap<>();
            map.put("id", m.getMenuId());
            map.put("name", m.getMname());
            map.put("open", false);      //设置是否展开
            List<HashMap<String, Object>> result1 = new ArrayList<>();
            List<Menu> children = m.getChildren();
            map.put("children", addfun(children, result1));
            result.add(map);
        }
        return result;
    }

}
